#!/bin/bash
#
ip="`ifconfig ens33 |awk -F '[ :]+' 'NR==2 {print $3}'`"
KUBERNETES_VERSION="v1.23.1"

sudo kubeadm init \
	--apiserver-advertise-address=$ip \
	--image-repository registry.aliyuncs.com/google_containers \
	--service-cidr=10.96.0.0/12 \
	--pod-network-cidr=10.244.0.0/16 \
	--kubernetes-version $KUBERNETES_VERSION

sudo mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g)  $HOME/.kube/config
kubectl get nodes

#部署calico网络插件
wget https://docs.projectcalico.org/manifests/calico.yaml 
kubectl apply -f calico.yaml
